#ifndef TCPCLIENT_H
#define TCPCLIENT_H
//#define TCPCLIENT_DEBUG 
#ifdef _WIN32
	#include "winsock2.h"
	#pragma  comment(lib,"WS2_32.LIB")
#else
	#include <arpa/inet.h>
	#include <errno.h>
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <unistd.h>
	#include <netinet/in.h>
	#include <netdb.h>
#endif
	#include <stdio.h>
	#include <string.h>
	using namespace std;

class TCPClient
{
public:
	TCPClient(void);
	~TCPClient(void);

	bool connectToServer(const char *serverIP,int serPort=0,int nTimeOut=-1);
	int  sendData(const unsigned char *data,int nLength,int nTimeOut=-1);
	int  receiveAllData(unsigned char *bufRecv,int nTimeOut=-1);
	void closeTcpSocket();

private:
	int  receive(unsigned char *data,int nBufLength,int nTimeOut=-1);
	int	 m_Socket;
	bool m_bConnect;
};
#endif
